﻿using Easy.Cloud.Communication.Sms.Core;
using Easy.Cloud.Communication.Sms.Submail;
using Easy.Cloud.Communication.Sms.Submail.Options;
using Microsoft.Extensions.DependencyInjection;
using System;

namespace Easy.Cloud.Communication.Sms.Submail
{
    public class SubmailSmsOptionsExtension : ISmsOptionsExtension
    {
        private readonly SubmailOptions _submailOptions;

        public SubmailSmsOptionsExtension(SubmailOptions option)
        {
            this._submailOptions = option;
        }

        public void AddServices(IServiceCollection services)
        {
            services.AddSingleton(__ => _submailOptions);

            services.AddScoped<ISmsClient, SubmailSmsClient>();

            services.AddScoped<SubmailSmsClient>();

            services.AddHttpClient(nameof(SubmailSmsClient), httpClient => { httpClient.BaseAddress = new Uri(Constants.BasicUrl); });
        }
    }
}